import java.math.RoundingMode;
import java.text.DecimalFormat;

import javax.swing.*;

/**
 * Abstract class gathering all members and methods common to Periplasm and Cell
 * @author Luc Peres
 * @version 2.0
 */

public abstract class Area {
	
	protected double GSH;
	protected double GSSG;
	protected double O2;
	protected double Gor;
	protected double ArcB;
	protected double ArcAP;
	protected double Cbl;
	protected double gshA;
	protected double gshB;
	protected double put;
	protected double fimB;
	protected double FimB;
	protected double fimS;
	
	/**
	 * Area constructor
	 */
	public Area(){
		this.GSH = 0;
		this.GSSG = 0;
		this.O2 = 0;
		this.Gor = 0;
		this.ArcB = 0;
		this.ArcAP = 0;
		this.Cbl = 0;
		this.gshA = 0;
		this.gshB = 0;
		this.put = 0;
		this.fimB = 0;
		this.FimB = 0;
		this.fimS = 0;
	}
	
	/**
	 * All getters for each member of the Area Class
	 */
	public double getGSH() {
		return this.GSH;
	}
	
	public double getGSSG() {
		return this.GSSG;
	}
	
	public double getO2() {
		return this.O2;
	}
	
	public double getGor() {
		return this.Gor;
	}
	
	public double getArcB() {
		return this.ArcB;
	}
	
	public double getArcAP() {
		return this.ArcAP;
	}
	
	public double getCbl() {
		return this.Cbl;
	}
	
	public double getgshA() {
		return this.gshA;
	}
	
	public double getgshB() {
		return this.gshB;
	}
	
	public double getput() {
		return this.put;
	}
	
	public double getfimB() {
		return this.fimB;
	}
	
	public double getFimB() {
		return this.FimB;
	}
	
	public double getfimS() {
		return this.fimS;
	}
	
	/**
	 * All setters for each member of the Area Class
	 */
	public void setGSH(double nb) {
		this.GSH = nb;
	}
	
	public void setGSSG(double nb) {
		this.GSSG = nb;
	}
	
	public void setO2(double nb) {
		this.O2 = nb;
	}
	
	public void setGor(double nb) {
		this.Gor = nb;
	}
	
	public void setArcB(double nb) {
		this.ArcB = nb;
	}
	
	public void setArcAP(double nb) {
		this.ArcAP = nb;
	}
	
	public void setCbl(double nb) {
		this.Cbl = nb;
	}
	
	public void setgshA(double nb) {
		this.gshA = nb;
	}
	
	public void setgshB(double nb) {
		this.gshB = nb;
	}
	
	public void setput(double nb) {
		this.put = nb;
	}
	
	public void setfimB(double nb) {
		this.fimB = nb;
	}
	
	public void setFimB(double nb) {
		this.FimB = nb;
	}
	
	public void setfimS(double nb) {
		this.fimS = nb;
	}
	
	/**
	 * Prints at each cycle the members' values in the window's textArea
	 * @param textArea: Window's textArea
	 * @param className: Which instance has to be printed (Periplasm or Cell)
	 */
	public void print(JTextArea textArea, String className){
		DecimalFormat f = new DecimalFormat();
		f.setMaximumFractionDigits(3);
		f.setRoundingMode(RoundingMode.HALF_UP);
		textArea.setText(textArea.getText() + "\nGSH:" + f.format(this.GSH));
		textArea.setText(textArea.getText() + "\tGSSG:" + f.format(this.GSSG));
		if (className.equals("Periplasm"))
			textArea.setText(textArea.getText() + "\tO2:" +  f.format(this.O2));
		else if (className.equals("Cell")) {
			textArea.setText(textArea.getText() + "\tGor:" + f.format(this.Gor));
			textArea.setText(textArea.getText() + "\tArcB:" + f.format(this.ArcB));
			textArea.setText(textArea.getText() + "\tArcA-P:" + f.format(this.ArcAP));
			textArea.setText(textArea.getText() + "\tCbl:" + f.format(this.Cbl));
			textArea.setText(textArea.getText() + "\tgshA:" + f.format(this.gshA));
			textArea.setText(textArea.getText() + "\tgshB:" + f.format(this.gshB));
			textArea.setText(textArea.getText() + "\tput (PA):" + f.format(this.put));
			textArea.setText(textArea.getText() + "\tfimB:" + f.format(this.fimB));
			textArea.setText(textArea.getText() + "\tFimB:" + f.format(this.FimB));
			textArea.setText(textArea.getText() + "\tfimS:" + f.format(this.fimS));
			textArea.setText(textArea.getText() + "\n");
		}
	}
	
	/**
	 * Method defined in Cell and Periplasm
	 */
	public abstract void initialize();

}
